package cn.edu.uestc.smgt.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.edu.uestc.smgt.pojo.Manager;
import cn.edu.uestc.smgt.pojo.User;

@Controller
@RequestMapping("/logout/")
public class LogoutController {
	/**
	 * 管理员登出
	 * 
	 * @throws IOException
	 */
	@RequestMapping("mgr")
	public void mgrLogout(HttpServletResponse response, HttpSession session) throws IOException {
		Manager mgr = (Manager) session.getAttribute("manager");
		if (mgr == null) {
			response.sendRedirect("/studentmanagement/login.html");
			return;
		}
		session.removeAttribute("manager");
		response.sendRedirect("/studentmanagement/login.html");
	}

	/**
	 * 二级用户登出
	 * 
	 * @throws IOException
	 */
	@RequestMapping("yh")
	public void yhLogout(HttpServletResponse response, HttpSession session) throws IOException {
		User yh = (User) session.getAttribute("user");
		if (yh == null) {
			response.sendRedirect("/studentmanagement/yh/login.html");
			return;
		}
		session.removeAttribute("user");
		response.sendRedirect("/studentmanagement/yh/login.html");
	}
}
